﻿CREATE VIEW [acms].[TopicFile_View]
AS 
	SELECT        
		b.Id, 
		b.TopicId, 
		b.FileId, 
		b.Name, 
		a.Size, 
		a.FileType, 
		a.ContentType, 
		a.Extension, 
		a.Width, 
		a.Height,
		c.Name as TopicName,
		b.VersionId
	FROM
		acms.Files AS a 
		INNER JOIN acms.TopicFiles AS b ON a.Id = b.FileId
		INNER JOIN acms.Topics AS c ON b.TopicId = c.Id
	WHERE        
		a.Deleted = 0 and b.Deleted = 0 and c.Deleted = 0
;